<?php
$response = $this->twitter->oAuthAccessToken($oauth_token, $oauth_verifier);

$oauth_token = $response['oauth_token'];
$oauth_token_secret = $response['oauth_token_secret'];
$twitter_user_id = $response['user_id'];
$twitter_screen_name = $response['screen_name'];
?>
<html>
    <head>
    </head>
    <body>
        <script type="text/javascript">
            var form = null;

            if (opener.document.signup_form != undefined) {
                form = opener.document.signup_form;
            } else {
                form = opener.document.edit_profile_form;
            }

            form.twitter_username.value = '<?php echo $twitter_screen_name; ?>';
            form.oauth_token.value = '<?php echo $oauth_token; ?>';
            form.oauth_token_secret.value = '<?php echo $oauth_token_secret; ?>';

            opener.document.getElementById('twitter-user-link').innerHTML = '<?php echo $twitter_screen_name; ?>';
            opener.document.getElementById('twitter-user-link').href = 'http://twitter.com/<?php echo $twitter_screen_name; ?>';
            opener.document.getElementById('twitter-buttton-link').style.display = 'none';
            opener.document.getElementById('twitter-user').style.display = 'inline';

            self.close();
        </script>
    </body>
</html>